package com.michael.provider;

import com.michael.assist.anno.DoLog;
import com.michael.common.error.exception.BizException;
import com.michael.facade.model.req.home.HomeIndexReq;
import com.michael.facade.model.res.home.HomeIndexRes;
import com.michael.facade.service.HomeFacade;
import com.michael.provider.convertor.HomeConvertor;
import com.michael.service.HomeService;
import com.michael.service.bizReq.HomeIndexBizReq;
import com.michael.service.bizRes.HomeIndexBizRes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HomeProvider implements HomeFacade {
    @Autowired
    private HomeService homeService;

    @Override
    @DoLog
    public HomeIndexRes index(HomeIndexReq req) throws BizException {
        HomeIndexBizReq bizReq = new HomeIndexBizReq();
        bizReq.setMessage(req.getMessage());
        /**
         * next layer handler
         */
        HomeIndexBizRes res = homeService.index(bizReq);
        res.setMessage(res.getMessage());
        return HomeConvertor.index(res);
    }
}
